package net.liteheaven.xblib.plugin;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

public class IntentHandlerImpl implements IntentHandler {

    @Override
    public void markAsPlugin(Context context, Intent intent) {
        String className = intent.getComponent().getClassName();
        if (TextUtils.isEmpty(className)){
            throw new IllegalArgumentException("className cannot be null.");
        }
        intent.putExtra(XPluginConst.PLUGIN_ACTIVITY_NAME, className);
        intent.setClass(context, XProxyActivity.class);
    }

    @Override
    public void attachPlugin(String apkPath, Intent intent) {
        intent.putExtra(XPluginConst.PLUGIN_NAME, apkPath);
    }
}
